var zoneLayer; //就业岗位分布大区图层

function loadZone() {
  if (zoneLayer) {
    map.removeLayer(zoneLayer, true);
  }
  // 加载街道分区数据
  zoneLayer = new mars3d.layer.GeoJsonLayer({
    // url: "https://wckj2020.obs.cn-south-1.myhuaweicloud.com:443/bjRegion.json",
    url: "../example/res/data/xzZone.json",
    mask: false, //标识为遮罩层【重点参数】
    name: "分区数据",
    symbol: {
      type: "polygon",
      styleOptions: {
        fill: false,
        // color: "rgb(2,26,79)",
        opacity: 0.7,
        outline: true,
        outlineColor: "#F8F8FF",
        outlineWidth: 3,
        outlineOpacity: 0.8,
        clampToGround: true,

        label: {
          //面中心点，显示文字的配置
          text: "{name}", //对应的属性名称
          opacity: 1,
          font_size: 20,
          color: "#ffffff",

          font_family: "微软雅黑",
          outline: true,
          outlineColor: "#000000",
          outlineWidth: 5,

          background: false,
          backgroundColor: "#000000",
          backgroundOpacity: 0.1,

          font_weight: "bolder",
          font_style: "normal",

          scaleByDistance: true,
          scaleByDistance_far: 200000,
          scaleByDistance_farValue: 0.5,
          scaleByDistance_near: 70000,
          scaleByDistance_nearValue: 1,

          distanceDisplayCondition: false,
          distanceDisplayCondition_far: 70000,
          distanceDisplayCondition_near: 0,
          visibleDepth: false,
        },
      },
      // callback: function (attr, styleOpt) {
      //   // console.log(hwIndex[attr.adcode]);
      //   if (hwIndex[attr.adcode] <= 2) {
      //     styleOpt.color = "rgb(38,192,34)";
      //   } else if (0 < hwIndex[attr.adcode] && hwIndex[attr.adcode] <= 5) {
      //     styleOpt.color = "rgb(154,252,43)";
      //   } else if (5 < hwIndex[attr.adcode] && hwIndex[attr.adcode] <= 10) {
      //     styleOpt.color = "rgb(252,255,44)";
      //   } else if (10 < hwIndex[attr.adcode] && hwIndex[attr.adcode] <= 20) {
      //     styleOpt.color = "rgb(245,149,29)";
      //   } else if (20 < hwIndex[attr.adcode] && hwIndex[attr.adcode] <= 40) {
      //     styleOpt.color = "rgb(250,209,39)";
      //   } else {
      //     styleOpt.color = "rgb(232,4,29)";
      //   }
      // },
    },
  });
  map.addLayer(zoneLayer);
}
